package com.run;

import com.image.Computer;
import com.image.Person;
import com.image.Result;
import com.thread.GameThread;
import com.winlose.WinLoseImpl;
import lombok.extern.slf4j.Slf4j;

import java.util.Random;
import java.util.Scanner;

@Slf4j
public class RSP {
    public static void main(String[] args) {

        Random random = new Random();
        Person person1 = new Person();
        Computer computer1 = new Computer();
        WinLoseImpl standard = new WinLoseImpl();
        Scanner scanner = new Scanner(System.in);

        person1.setName("player1");
        computer1.setName("computer1");

        log.info(person1.getName() + " PK " + computer1.getName() + "欢迎游玩石头剪刀布：5局游戏");

        for(int i = 1; i <= 5; i++) {

            log.info("第"+ i +"局" + "请出拳");

            computer1.setComnum(random.nextInt(3) + 1);
            person1.setHand(scanner.next());

            int person = person1.printPersonResult(person1.getHand());
            computer1.printComputerResult(computer1.getComnum());

            int computer = computer1.getComnum();
            int result = standard.rule(person, computer);

            if(result == 1){
                /*1.平局*/
                Result.resultAddPing();
            }else if (result == 2){
                /*2.赢局*/
                Result.resultAddYing();
            }else if (result == 3){
                /*3.输局*/
                Result.resultAddShu();
            }else {
                log.info("输入错误,这局不算");
                continue;
            }
        }
        log.info("平局：" + Result.p + " 胜场：" + Result.y + " 败场：" + Result.s);
    }
}
